Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails javascript_include_tag

I have a few custom .js files in my public/javascripts folder. The 'javascript_include_tag' adds script tags to the head element. Are these executed in the order in which they appear. If yes, how do I control the order in which these script tags are added to my html.

thanks, ash

like image 416
user290870 Avatar asked May 21 '10 20:05

user290870


People also ask

What is Javascript_include_tag?

javascript_include_tag(*sources) Link. Returns an HTML script tag for each of the sources provided. Sources may be paths to JavaScript files. Relative paths are assumed to be relative to public/javascripts , full paths are assumed to be relative to the document root.

Where is JavaScript folder in rails 7?

Go to app/javascript/application.


1 Answers

Yes, they are executed in order of appearance, so you just write them in the order you want. If you are currently using javascript_include_tag :all then you can include individual scripts instead to get the order you want:

javascript_include_tag :defaults
javascript_include_tag "script_1"
javascript_include_tag "script_2"
like image 81
Alex Korban Avatar answered Sep 30 '22 16:09

Alex Korban