Load dynamic css in javascript -
i have javascript file other people use on site. creates button , loads css file hosted on our server:
style.setattribute('href', 'http://mysite.com/assets/some.css');
the user can call in site so:
<script type="text/javascript" src="http://mysite.com/global.js"></script>
i want give user ability upload own css file on web app replace 1 setting in global.js
.
currently, added custom_css:binary
column in users
table hold css file, requires user stay signed in on site. i'm not sure if right way approach or if there better way it. also, security risks approach?
i'm using ror backend.
any great!
update 1
i'm able store uploaded js file , load custom css, it's checking current_user
- means stylesheet not rendered users. how can work around this?
i able find solution myself.
there several ways approach this:
- add query string js src
- scrape page element gets generated script
i opted option 1. when detect dynamically generated query string, send on controller in params
hash , load css file accordingly.