javascript - Why does script file that's loaded before jQuery still work? -
i planning load jquery on cdn rails app. unfortunately unable show code, i'll try explain. code set follows:
in layout, before closing body tag:
= javascript_include_tag "main_web"
main_web.js:
//= require jquery //= require page_script
now want do,
in layout
= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" = javascript_include_tag "main_web"
and in main_web.js remove jquery dependency
//=require page_script
i did , have waterfall looks this:
i want sure when implement change, none of visitors' browsers try execute main_script before jquery loaded.
not 100% sure of scripts or how rendered on page javascript files loaded markup executed sequentially. therefore if have 2 script files in page:
<script src="filea.js"></script> <script src="fileb.js"></script>
filea.js execute before fileb.js
this situation occurring in example without knowing how loaded cannot sure.
Comments
Post a Comment