0

I am learning ruby on rails and javascript. Is there anyway to load js file only when needed by the railsapp? I tried to create simple application but when I check on the log, I realize it always load all the js, even the unneeded library.

I already searched it and found that it is using configuration to load a specific js only for specific pages.It's good, but I guess when we deal with a library that is used by many pages,, will make it hard to maintain. Could anyone give a good advice?

thank you

1 Answer 1

1

Take a look at requireJS : http://requirejs.org/

RequireJS is a JavaScript file and module loader. 
It is optimized for in-browser use, but it can be
used in other JavaScript environments, like Rhino and Node. Using a 
modular script loader like RequireJS will improve the speed and quality of your code.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.