inline script

92 views
Skip to first unread message

Philip Harrison

unread,
Nov 23, 2011, 8:01:59 PM11/23/11
to der...@googlegroups.com
Hey, 

Really liking what I'm seeing here.

While playing around, I found myself in the situation of wanting to have a inline script have access to exported methods from the controller. 

What is the preferred way of doing this? 

My current solution: 

Should I stuff that in the ready fn instead? 

Cheers

Philip Harrison

unread,
Nov 23, 2011, 9:05:37 PM11/23/11
to der...@googlegroups.com
Also isn't <script defer async> the same as just setting <script async> ? 
As far as I know the only difference is in execution. Did some ugly testing and this seemed to be the case in safari/chrome. Makes sense when async has higher execution priority.

Nate Smith

unread,
Nov 27, 2011, 8:47:00 PM11/27/11
to der...@googlegroups.com
The idea behind the inline script is that it runs immediately, before any of the external scripts are loaded. This should only be used in rare cases where the script should run before the page is displayed in the browser, such as sizing something to the window or autofuocusing an element in browsers that don't support the "autofocus" attribute.

Is there a reason why you would want to include this in the inline script instead of in the app's script file? If you are waiting for the external file to load anyway, then isn't this the same as including the functions in the app's script?


In browsers that support async, the defer won't change anything. However, there are a number of old browsers (most IE versions and some versions of Firefox) that support defer and not async. Adding defer can help those browsers to render a little faster.

- Nate
Reply all
Reply to author
Forward
0 new messages