single file includes dilemma

classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|

single file includes dilemma

shelane
So I have been hearing more and more that scripts should be put at the
bottom of the page - before the </body>.

If I use a single file method for my applications, I may need to do some
scripting in a section that requires a js file. If I'm not adding the js
file until later, this is a problem.

I was going to write a tag to handle "declaring" which js files I'd need and
insert a javascript code block into my tag to be output at the end of the
base file. I wanted to check with the community to see how you all are
handling it.



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Eric Landmann
On 12/8/09 at 4:16 PM, [hidden email] (Shelane Enos) wrote:

>So I have been hearing more and more that scripts should be put at the
>bottom of the page - before the </body>.
>
>If I use a single file method for my applications, I may need to do some
>scripting in a section that requires a js file. If I'm not adding the js
>file until later, this is a problem.
>
>I was going to write a tag to handle "declaring" which js files I'd need and
>insert a javascript code block into my tag to be output at the end of the
>base file. I wanted to check with the community to see how you all are
>handling it.

Shelane:

Here's something we use for itPage that inserts a small
Javascript at the just before the </body> if it is a login page.
It searches for the phrase "LoginForm" as the trigger. The JS
sets the focus to the User ID box on that form.

local:'PageEnd_regexp' = (regexp: -find='(\\s+)</body>',
-input=(Content_Body), -ignorecase);
if: #PageEnd_regexp->find == true;
     local: 'prefix' = #PageEnd_regexp->(matchstring: 1);
     local: 'lines' = array;
     if: (Content_Body) >> (regexp: -find='LoginForm');
         #lines->(insert: '<!-- Inserted by LI_CMSatend -->');
         #lines->(insert: '<script language="JavaScript" type="text/javascript">');
         #lines->(insert: '\t<!-- Set focus to User_LoginID in
login form -->');
         #lines->(insert: '\tdocument.LoginForm.User_LoginID.focus();');
         #lines->(insert: '</script>');
     /if;

     #PageEnd_regexp->(replacepattern: #prefix + #lines->(join:
#prefix) + #prefix + '</body>');
     (Content_Body) = #PageEnd_regexp->(replacefirst);

/if;

The original idea for this came from "An introduction to using
JQuery with Lasso" http://www.lassosoft.com/Documentation/TotW/index.lasso?9302

--Eric


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Ke Carlton-2
In reply to this post by shelane
You can do something similar to the below. We're not running this live
yet - it's in the process of being implemented / tested:

<html>
<header>
[javascript]
        <script src="http://www.google.com/jsapi"></script>
        <script>google.load("jquery","1.2.6");</script>
[/javascript]
</header>
<body>

<h1>Hi there...</h1>

[javascript]
        <script>$('h1').hide().fadeIn();</script>
[/javascript]

<p>Some other content</p>

[javascripts]

</body>
</html>

[//L8.5
define_tag('javascript',-container);
        ! var_defined('body_scripts')
        ? var('body_scripts') = array;

        lp_client_isBot // Bill's tag
        ? return(run_children)
        | $body_scripts->insert(run_children);
/define_tag;

define_tag:'javascripts',-encodenone;
        var('body_scripts')->isA('array')
        ? return($body_scripts->join('\r'));
/define_tag;
]

One good thing about this approach is that it still validates when
being checked by a bot. I guess you could modify it somewhat by adding
a -requires parameter which would then ensure any required libraries
are inserted before the current script - either via the Google JSAPI
or a simple src URL.

Ke

www.L-Debug.org

2009/12/9 Shelane Enos <[hidden email]>:

> So I have been hearing more and more that scripts should be put at the
> bottom of the page - before the </body>.
>
> If I use a single file method for my applications, I may need to do some
> scripting in a section that requires a js file. If I'm not adding the js
> file until later, this is a problem.
>
> I was going to write a tag to handle "declaring" which js files I'd need and
> insert a javascript code block into my tag to be output at the end of the
> base file. I wanted to check with the community to see how you all are
> handling it.

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Tim Taplin
In reply to this post by Eric Landmann
Can someone point me in the direction of some references to the logic behind why javascript should be at the bottom of the page? I seem to remember some discussion in the past but my recollection was that the cases where it mattered weren't worth the extra effort.

Perhaps its time I revisit the discussion so I can update my thinking.

Thanks in advance.

Tim Taplin

On Dec 8, 2009, at 3:28 PM, Eric Landmann wrote:

> On 12/8/09 at 4:16 PM, [hidden email] (Shelane Enos) wrote:
>
>> So I have been hearing more and more that scripts should be put at the
>> bottom of the page - before the </body>.
>>
>> If I use a single file method for my applications, I may need to do some
>> scripting in a section that requires a js file. If I'm not adding the js
>> file until later, this is a problem.
>>
>> I was going to write a tag to handle "declaring" which js files I'd need and
>> insert a javascript code block into my tag to be output at the end of the
>> base file. I wanted to check with the community to see how you all are
>> handling it.
>
> Shelane:
>
> Here's something we use for itPage that inserts a small Javascript at the just before the </body> if it is a login page. It searches for the phrase "LoginForm" as the trigger. The JS sets the focus to the User ID box on that form.
>
> local:'PageEnd_regexp' = (regexp: -find='(\\s+)</body>', -input=(Content_Body), -ignorecase);
> if: #PageEnd_regexp->find == true;
>    local: 'prefix' = #PageEnd_regexp->(matchstring: 1);
>    local: 'lines' = array;
>    if: (Content_Body) >> (regexp: -find='LoginForm');
>        #lines->(insert: '<!-- Inserted by LI_CMSatend -->');
>        #lines->(insert: '<script language="JavaScript" type="text/javascript">');
>        #lines->(insert: '\t<!-- Set focus to User_LoginID in login form -->');
>        #lines->(insert: '\tdocument.LoginForm.User_LoginID.focus();');
>        #lines->(insert: '</script>');
>    /if;
>
>    #PageEnd_regexp->(replacepattern: #prefix + #lines->(join: #prefix) + #prefix + '</body>');
>    (Content_Body) = #PageEnd_regexp->(replacefirst);
>
> /if;
>
> The original idea for this came from "An introduction to using JQuery with Lasso" http://www.lassosoft.com/Documentation/TotW/index.lasso?9302
>
> --Eric
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Ke Carlton-2
http://developer.yahoo.com/performance/rules.html

Essentially when javascript is included in the header the browser will
wait for it to download before rendering the rest of page. By having
it at the bottom, the browser has already rendered most of the page
before it hits the javascript request.

Ke

2009/12/9 Tim Taplin <[hidden email]>:
> Can someone point me in the direction of some references to the logic behind why javascript should be at the bottom of the page? I seem to remember some discussion in the past but my recollection was that the cases where it mattered weren't worth the extra effort.
>
> Perhaps its time I revisit the discussion so I can update my thinking.
>
> Thanks in advance.
>
> Tim Taplin

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Göran Törnquist-2
In reply to this post by Tim Taplin
The idea is that the DOM should be more or less rendered before you try
to execute or load any javascript that might modify it. Since the sub
requests of javascript files locks up the rendering until the javascript
file has been completely downloaded and processed, it makes sense to put
non-obtrusive enhancing javascript in the end of the html.

Read further here.

http://developer.yahoo.com/performance/rules.html

Check out the section addressing Javascript in the bottom.

/Göran

Tim Taplin wrote:

> Can someone point me in the direction of some references to the logic behind why javascript should be at the bottom of the page? I seem to remember some discussion in the past but my recollection was that the cases where it mattered weren't worth the extra effort.
>
> Perhaps its time I revisit the discussion so I can update my thinking.
>
> Thanks in advance.
>
> Tim Taplin
>
> On Dec 8, 2009, at 3:28 PM, Eric Landmann wrote:
>
>  
>> On 12/8/09 at 4:16 PM, [hidden email] (Shelane Enos) wrote:
>>
>>    
>>> So I have been hearing more and more that scripts should be put at the
>>> bottom of the page - before the </body>.
>>>
>>> If I use a single file method for my applications, I may need to do some
>>> scripting in a section that requires a js file. If I'm not adding the js
>>> file until later, this is a problem.
>>>
>>> I was going to write a tag to handle "declaring" which js files I'd need and
>>> insert a javascript code block into my tag to be output at the end of the
>>> base file. I wanted to check with the community to see how you all are
>>> handling it.
>>>      
>> Shelane:
>>
>> Here's something we use for itPage that inserts a small Javascript at the just before the </body> if it is a login page. It searches for the phrase "LoginForm" as the trigger. The JS sets the focus to the User ID box on that form.
>>
>> local:'PageEnd_regexp' = (regexp: -find='(\\s+)</body>', -input=(Content_Body), -ignorecase);
>> if: #PageEnd_regexp->find == true;
>>    local: 'prefix' = #PageEnd_regexp->(matchstring: 1);
>>    local: 'lines' = array;
>>    if: (Content_Body) >> (regexp: -find='LoginForm');
>>        #lines->(insert: '<!-- Inserted by LI_CMSatend -->');
>>        #lines->(insert: '<script language="JavaScript" type="text/javascript">');
>>        #lines->(insert: '\t<!-- Set focus to User_LoginID in login form -->');
>>        #lines->(insert: '\tdocument.LoginForm.User_LoginID.focus();');
>>        #lines->(insert: '</script>');
>>    /if;
>>
>>    #PageEnd_regexp->(replacepattern: #prefix + #lines->(join: #prefix) + #prefix + '</body>');
>>    (Content_Body) = #PageEnd_regexp->(replacefirst);
>>
>> /if;
>>
>> The original idea for this came from "An introduction to using JQuery with Lasso" http://www.lassosoft.com/Documentation/TotW/index.lasso?9302
>>
>> --Eric
>>
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>>
>>    
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>
>  


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

jasonhuck
http://devblog.jasonhuck.com/2008/09/23/an-asset-management-system-for-lasso-powered-sites/

no time to elaborate right now, but please read and consider!



--
Jason Huck
Director of Technology
Core Five Creative

2245 Gilbert Ave. 300
Cincinnati, OH 45206
v: 513.723.0101x16 | f: 513.362.2643

c|5 :: aligning brand & business


On Dec 8, 2009, at 6:16 PM, Göran Törnquist <[hidden email]> wrote:

> The idea is that the DOM should be more or less rendered before you  
> try to execute or load any javascript that might modify it. Since  
> the sub requests of javascript files locks up the rendering until  
> the javascript file has been completely downloaded and processed, it  
> makes sense to put non-obtrusive enhancing javascript in the end of  
> the html.
>
> Read further here.
>
> http://developer.yahoo.com/performance/rules.html
>
> Check out the section addressing Javascript in the bottom.
>
> /Göran
>
> Tim Taplin wrote:
>> Can someone point me in the direction of some references to the  
>> logic behind why javascript should be at the bottom of the page? I  
>> seem to remember some discussion in the past but my recollection  
>> was that the cases where it mattered weren't worth the extra effort.
>> Perhaps its time I revisit the discussion so I can update my  
>> thinking.
>>
>> Thanks in advance.
>>
>> Tim Taplin
>>
>> On Dec 8, 2009, at 3:28 PM, Eric Landmann wrote:
>>
>>
>>> On 12/8/09 at 4:16 PM, [hidden email] (Shelane Enos) wrote:
>>>
>>>
>>>> So I have been hearing more and more that scripts should be put  
>>>> at the
>>>> bottom of the page - before the </body>.
>>>>
>>>> If I use a single file method for my applications, I may need to  
>>>> do some
>>>> scripting in a section that requires a js file. If I'm not adding  
>>>> the js
>>>> file until later, this is a problem.
>>>>
>>>> I was going to write a tag to handle "declaring" which js files  
>>>> I'd need and
>>>> insert a javascript code block into my tag to be output at the  
>>>> end of the
>>>> base file. I wanted to check with the community to see how you  
>>>> all are
>>>> handling it.
>>>>
>>> Shelane:
>>>
>>> Here's something we use for itPage that inserts a small Javascript  
>>> at the just before the </body> if it is a login page. It searches  
>>> for the phrase "LoginForm" as the trigger. The JS sets the focus  
>>> to the User ID box on that form.
>>>
>>> local:'PageEnd_regexp' = (regexp: -find='(\\s+)</body>', -input=
>>> (Content_Body), -ignorecase);
>>> if: #PageEnd_regexp->find == true;
>>>   local: 'prefix' = #PageEnd_regexp->(matchstring: 1);
>>>   local: 'lines' = array;
>>>   if: (Content_Body) >> (regexp: -find='LoginForm');
>>>       #lines->(insert: '<!-- Inserted by LI_CMSatend -->');
>>>       #lines->(insert: '<script language="JavaScript" type="text/
>>> javascript">');
>>>       #lines->(insert: '\t<!-- Set focus to User_LoginID in login  
>>> form -->');
>>>       #lines->(insert: '\tdocument.LoginForm.User_LoginID.focus
>>> ();');
>>>       #lines->(insert: '</script>');
>>>   /if;
>>>
>>>   #PageEnd_regexp->(replacepattern: #prefix + #lines->(join:  
>>> #prefix) + #prefix + '</body>');
>>>   (Content_Body) = #PageEnd_regexp->(replacefirst);
>>>
>>> /if;
>>>
>>> The original idea for this came from "An introduction to using  
>>> JQuery with Lasso" http://www.lassosoft.com/Documentation/TotW/index.lasso?9302
>>>
>>> --Eric
>>>
>>>
>>> --
>>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>>
>>>
>>>
>>
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>>
>>
>>
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

shelane
In reply to this post by Ke Carlton-2
I ended up remembering the collect tags that Fletcher wrote some time ago
that did about the same thing. However, this is a very elegant approach and
I'll file it for later use :-)


On 12/8/09 3:06 PM, "Ke Carlton" <[hidden email]> wrote:

> You can do something similar to the below. We're not running this live
> yet - it's in the process of being implemented / tested:
>
> <html>
> <header>
> [javascript]
> <script src="http://*www.*google.com/jsapi"></script>
> <script>google.load("jquery","1.2.6");</script>
> [/javascript]
> </header>
> <body>
>
> <h1>Hi there...</h1>
>
> [javascript]
> <script>$('h1').hide().fadeIn();</script>
> [/javascript]
>
> <p>Some other content</p>
>
> [javascripts]
>
> </body>
> </html>
>
> [//L8.5
> define_tag('javascript',-container);
> ! var_defined('body_scripts')
> ? var('body_scripts') = array;
>
> lp_client_isBot // Bill's tag
> ? return(run_children)
> | $body_scripts->insert(run_children);
> /define_tag;
>
> define_tag:'javascripts',-encodenone;
> var('body_scripts')->isA('array')
> ? return($body_scripts->join('\r'));
> /define_tag;
> ]
>
> One good thing about this approach is that it still validates when
> being checked by a bot. I guess you could modify it somewhat by adding
> a -requires parameter which would then ensure any required libraries
> are inserted before the current script - either via the Google JSAPI
> or a simple src URL.
>
> Ke
>
> www.*L-Debug.org
>
> 2009/12/9 Shelane Enos <[hidden email]>:
>> So I have been hearing more and more that scripts should be put at the
>> bottom of the page - before the </body>.
>>
>> If I use a single file method for my applications, I may need to do some
>> scripting in a section that requires a js file. If I'm not adding the js
>> file until later, this is a problem.
>>
>> I was going to write a tag to handle "declaring" which js files I'd need and
>> insert a javascript code block into my tag to be output at the end of the
>> base file. I wanted to check with the community to see how you all are
>> handling it.
>
> --
> This list is a free service of LassoSoft: http://*www.*LassoSoft.com/
> Search the list archives: http://*www.*ListSearch.com/Lasso/Browse/
> Manage your subscription: http://*www.*ListSearch.com/Lasso/
>
>
>



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Robert Carpenter
In reply to this post by Tim Taplin
As others have pointed out, Javascript links can block loading and  
rendering of the page content. The issue is becoming more a problem  
because folks are including more and more js files to make whizzy web  
2.0 sites.

Some folks are trying to address the blocking issue with various  
methods of deferred or lazy-loading your scripts:

http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/

-robert-

On Dec 8, 2009, at 3:07 PM, Tim Taplin wrote:

> Can someone point me in the direction of some references to the  
> logic behind why javascript should be at the bottom of the page? I  
> seem to remember some discussion in the past but my recollection was  
> that the cases where it mattered weren't worth the extra effort.
>
> Perhaps its time I revisit the discussion so I can update my thinking.
>
> Thanks in advance.
>
> Tim Taplin
>
> On Dec 8, 2009, at 3:28 PM, Eric Landmann wrote:
>
>> On 12/8/09 at 4:16 PM, [hidden email] (Shelane Enos) wrote:
>>
>>> So I have been hearing more and more that scripts should be put at  
>>> the
>>> bottom of the page - before the </body>.
>>>
>>> If I use a single file method for my applications, I may need to  
>>> do some
>>> scripting in a section that requires a js file. If I'm not adding  
>>> the js
>>> file until later, this is a problem.
>>>
>>> I was going to write a tag to handle "declaring" which js files  
>>> I'd need and
>>> insert a javascript code block into my tag to be output at the end  
>>> of the
>>> base file. I wanted to check with the community to see how you all  
>>> are
>>> handling it.
>>
>> Shelane:
>>
>> Here's something we use for itPage that inserts a small Javascript  
>> at the just before the </body> if it is a login page. It searches  
>> for the phrase "LoginForm" as the trigger. The JS sets the focus to  
>> the User ID box on that form.
>>
>> local:'PageEnd_regexp' = (regexp: -find='(\\s+)</body>', -
>> input=(Content_Body), -ignorecase);
>> if: #PageEnd_regexp->find == true;
>>   local: 'prefix' = #PageEnd_regexp->(matchstring: 1);
>>   local: 'lines' = array;
>>   if: (Content_Body) >> (regexp: -find='LoginForm');
>>       #lines->(insert: '<!-- Inserted by LI_CMSatend -->');
>>       #lines->(insert: '<script language="JavaScript" type="text/
>> javascript">');
>>       #lines->(insert: '\t<!-- Set focus to User_LoginID in login  
>> form -->');
>>       #lines->(insert: '\tdocument.LoginForm.User_LoginID.focus();');
>>       #lines->(insert: '</script>');
>>   /if;
>>
>>   #PageEnd_regexp->(replacepattern: #prefix + #lines->(join:  
>> #prefix) + #prefix + '</body>');
>>   (Content_Body) = #PageEnd_regexp->(replacefirst);
>>
>> /if;
>>
>> The original idea for this came from "An introduction to using  
>> JQuery with Lasso" http://www.lassosoft.com/Documentation/TotW/index.lasso?9302
>>
>> --Eric
>>
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Johan Solve
In reply to this post by Ke Carlton-2
Nice Ke, but you could do with just the container tag and not the
extra javascripts tag by defining an define_atend that will insert the
scripts in $body_scripts automatically right before </body>. A little
bit more handy.

On Wed, Dec 9, 2009 at 12:06 AM, Ke Carlton <[hidden email]> wrote:

> You can do something similar to the below. We're not running this live
> yet - it's in the process of being implemented / tested:
>
> <html>
> <header>
> [javascript]
>        <script src="http://www.google.com/jsapi"></script>
>        <script>google.load("jquery","1.2.6");</script>
> [/javascript]
> </header>
> <body>
>
> <h1>Hi there...</h1>
>
> [javascript]
>        <script>$('h1').hide().fadeIn();</script>
> [/javascript]
>
> <p>Some other content</p>
>
> [javascripts]
>
> </body>
> </html>
>
> [//L8.5
> define_tag('javascript',-container);
>        !       var_defined('body_scripts')
>        ?       var('body_scripts') = array;
>
>        lp_client_isBot // Bill's tag
>        ?       return(run_children)
>        |       $body_scripts->insert(run_children);
> /define_tag;
>
> define_tag:'javascripts',-encodenone;
>        var('body_scripts')->isA('array')
>        ? return($body_scripts->join('\r'));
> /define_tag;
> ]
>
> One good thing about this approach is that it still validates when
> being checked by a bot. I guess you could modify it somewhat by adding
> a -requires parameter which would then ensure any required libraries
> are inserted before the current script - either via the Google JSAPI
> or a simple src URL.
>
> Ke
>
> www.L-Debug.org
>
> 2009/12/9 Shelane Enos <[hidden email]>:
>> So I have been hearing more and more that scripts should be put at the
>> bottom of the page - before the </body>.
>>
>> If I use a single file method for my applications, I may need to do some
>> scripting in a section that requires a js file. If I'm not adding the js
>> file until later, this is a problem.
>>
>> I was going to write a tag to handle "declaring" which js files I'd need and
>> insert a javascript code block into my tag to be output at the end of the
>> base file. I wanted to check with the community to see how you all are
>> handling it.
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>



--
Mvh
Johan Sölve
____________________________________
Montania System AB
Halmstad   Stockholm   Malmö
http://www.montania.se

Johan Sölve
Mobil +46 709-51 55 70
[hidden email]

Kristinebergsvägen 17, S-302 41 Halmstad, Sweden
Telefon +46 35-136800 |  Fax +46 35-136801

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Eric Landmann
On 12/9/09 at 7:20 PM, [hidden email] (Johan Solve) wrote:

> Nice Ke, but you could do with just the container tag and not the
> extra javascripts tag by defining an define_atend that will insert the
> scripts in $body_scripts automatically right before </body>. A little
> bit more handy.

Is there a problem with my approach? It is the one Fletcher recommended.

--Eric


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

stevepiercy
On 12/8/09 at 8:02 PM, [hidden email] (Eric
Landmann) pronounced:

>On 12/9/09 at 7:20 PM, [hidden email] (Johan Solve) wrote:
>
>>Nice Ke, but you could do with just the container tag and not the
>>extra javascripts tag by defining an define_atend that will insert the
>>scripts in $body_scripts automatically right before </body>. A little
>>bit more handy.
>
>Is there a problem with my approach? It is the one Fletcher recommended.

Yes and no.

For a single tiny javascript and nothing more, then it is OK to
use this method.

For the situation where you rely upon a javascript library and
many plugins for various GUI bits, this method is difficult to
maintain.  It also leads to large page sizes because you embed
the javascripts within the page.  In this case it is usually
better to allow the client to download external .js files and
cache them so that the same content does not get repeatedly sent
to the client.  When you start to have many externally
referenced .js and .css files, you realize that there has to be
a better, more efficient way.

You might combine all the external javascripts together into a
single javascript, minify it, write it to the filesystem, and
cache it.  While you're at it, why not do the same for the
external CSS files that the javascript libraries use?

Jason's asset management system does this and more.  You can
selectively apply which .js and .css to combine at any level,
from global to page to module (like your login DIV).

http://devblog.jasonhuck.com/2008/09/23/an-asset-management-system-for-lasso-powered-sites/

     The second half of my presentation described an asset management
     system for Lasso which manages the JavaScript and CSS files used
     throughout the site, automating many of the aforementioned best
     practices by handling the concatenation, minification (via YUI
     Compressor), compression, caching, and integration of JavaScript
     and CSS files. The system is designed to be adaptable to any
     Lasso framework or codebase without substantially impacting
     existing workflows, and can easily be partially or completely
     disabled for debugging purposes.

--steve

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

jasonhuck
In reply to this post by Ke Carlton-2
If you take this approach, I'd recommend that the external scripts be
fetched by the tag, and the inline scripts be extracted from their
<script> tags, so that you can concatenate the results into a single
file, minify it, compress it, write it to disk with a unique filename,
and then insert a link to that single, cacheable file.

The exception would be for scripts like jQuery or Google Analytics
which are so commonly served from the same location that they are
likely already in the user's browser cache.

The same goes for CSS files.

Not only does it make a significant improvement in performance, it can
also simplify and streamline your workflow and create better coding
and development habits. You're less tempted to be lazy and sneak a
dirty little inline script or style into your nice clean markup when
you have a simple, systematic, and automated way of properly adding it
externally, and finding things later when you need to make changes is
much, much easier than wrestling with one super-massive disorganized
CSS file or a mess of inline styles buried in your markup.

- Jason




On Tue, Dec 8, 2009 at 6:06 PM, Ke Carlton <[hidden email]> wrote:

> You can do something similar to the below. We're not running this live
> yet - it's in the process of being implemented / tested:
>
> <html>
> <header>
> [javascript]
>        <script src="http://www.google.com/jsapi"></script>
>        <script>google.load("jquery","1.2.6");</script>
> [/javascript]
> </header>
> <body>
>
> <h1>Hi there...</h1>
>
> [javascript]
>        <script>$('h1').hide().fadeIn();</script>
> [/javascript]
>
> <p>Some other content</p>
>
> [javascripts]
>
> </body>
> </html>
>
> [//L8.5
> define_tag('javascript',-container);
>        !       var_defined('body_scripts')
>        ?       var('body_scripts') = array;
>
>        lp_client_isBot // Bill's tag
>        ?       return(run_children)
>        |       $body_scripts->insert(run_children);
> /define_tag;
>
> define_tag:'javascripts',-encodenone;
>        var('body_scripts')->isA('array')
>        ? return($body_scripts->join('\r'));
> /define_tag;
> ]
>
> One good thing about this approach is that it still validates when
> being checked by a bot. I guess you could modify it somewhat by adding
> a -requires parameter which would then ensure any required libraries
> are inserted before the current script - either via the Google JSAPI
> or a simple src URL.
>
> Ke
>
> www.L-Debug.org
>
> 2009/12/9 Shelane Enos <[hidden email]>:
>> So I have been hearing more and more that scripts should be put at the
>> bottom of the page - before the </body>.
>>
>> If I use a single file method for my applications, I may need to do some
>> scripting in a section that requires a js file. If I'm not adding the js
>> file until later, this is a problem.
>>
>> I was going to write a tag to handle "declaring" which js files I'd need and
>> insert a javascript code block into my tag to be output at the end of the
>> base file. I wanted to check with the community to see how you all are
>> handling it.
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>



--
tagSwap.net :: Open Source Lasso Code
<http://tagSwap.net/>

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Ke Carlton-2
In reply to this post by Johan Solve
Yes, good point. Have used that approach somewhere else...

2009/12/9 Johan Solve <[hidden email]>:
> Nice Ke, but you could do with just the container tag and not the
> extra javascripts tag by defining an define_atend that will insert the
> scripts in $body_scripts automatically right before </body>. A little
> bit more handy.

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Bil Corry-3
In reply to this post by jasonhuck
Jason Huck wrote on 12/8/2009 6:31 PM:
> Not only does it make a significant improvement in performance, it can
> also simplify and streamline your workflow and create better coding
> and development habits. You're less tempted to be lazy and sneak a
> dirty little inline script or style into your nice clean markup when
> you have a simple, systematic, and automated way of properly adding it
> externally, and finding things later when you need to make changes is
> much, much easier than wrestling with one super-massive disorganized
> CSS file or a mess of inline styles buried in your markup.

Another advantage to external JS files, you'll be able to implement CSP (Content Security Policy) with some ease:

        http://people.mozilla.org/~bsterne/content-security-policy/index.html

The formal spec lives here:

        https://wiki.mozilla.org/Security/CSP/Spec

A CSP-enabled version of Firefox is available here:

        http://people.mozilla.org/~bsterne/content-security-policy/download.html


- Bil


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Jussi Hirvi-2
As long as it's jquery, does not
        $(document).ready(function()
solve the problem? I understand it should take care of letting the whole
document load before executing the javascript. Here is some more context:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>google.load("jquery", "1.3.2");</script>
<script>
        $(document).ready(function(){
           // the actual script should be placed here
        });
</script>

- Jussi

--
Jussi Hirvi * Green Spot
Topeliuksenkatu 15 C * 00250 Helsinki * Finland
Tel. +358 9 493 981 * Mobile +358 40 771 2098 (only sms)
[hidden email] * http://www.greenspot.fi

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

stevepiercy
Only under limited circumstances, e.g., no plugins or other
scripts, you have no pages that don't need the javascript,
minification and compression not desired, etc.

Details:
http://devblog.jasonhuck.com/2008/09/23/an-asset-management-system-for-lasso-powered-sites/

--steve


On 12/9/09 at 12:35 PM, [hidden email] (Jussi Hirvi) pronounced:

>As long as it's jquery, does not
>$(document).ready(function()
>solve the problem? I understand it should take care of letting
>the whole document load before executing the javascript. Here
>is some more context:
>
><script type="text/javascript" src="http://www.google.com/jsapi"></script>
><script>google.load("jquery", "1.3.2");</script>
><script>
>$(document).ready(function(){
>// the actual script should be placed here
>});
></script>
>
>- Jussi
>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Steve Piercy               Web Site Builder              
Soquel, CA
<[hidden email]>                  <http://www.StevePiercy.com/>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

dguardiola
In reply to this post by jasonhuck

Le 9 déc. 09 à 00:19, Jason Huck a écrit :

> http://devblog.jasonhuck.com/2008/09/23/an-asset-management-system-for-lasso-powered-sites/

I wanted to use your asset system but still had no time to implement  
it Jason
Will it be able to run under Lasso 9 (with syntax changes perhaps)?

Dominique
--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

Bil Corry-3
In reply to this post by Jussi Hirvi-2
Jussi Hirvi wrote on 12/9/2009 2:35 AM:
> As long as it's jquery, does not
>     $(document).ready(function()
> solve the problem? I understand it should take care of letting the whole
> document load before executing the javascript. Here is some more context:
>
> <script type="text/javascript" src="http://www.google.com/jsapi"></script>

Must be loaded, parsed, and executed.

> <script>google.load("jquery", "1.3.2");</script>

Must be loaded, parsed, and executed.

> <script>
>     $(document).ready(function(){
>        // the actual script should be placed here
>     });
> </script>

Must be loaded (done), parsed, and inserted into the queue to be executed.

If you place all of the above at the bottom of the page, then it'll do all of that AFTER the page has mostly loaded/rendered.  The onReady function is mostly so that jQuery can make sure the DOM you want to modify is actually present (especially a problem when it's at the top of the page and the DOM hasn't even been parsed yet).


- Bil


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: single file includes dilemma

jasonhuck
In reply to this post by dguardiola
I'm sure it will need some syntax changes to run under 9, but I have
no idea how extensive they will be, and can't provide any sort of
timeframe for when we'll be able to release an updated version.

- jason



On Wed, Dec 9, 2009 at 6:07 AM, Dominique Guardiola
<[hidden email]> wrote:

>
> Le 9 déc. 09 à 00:19, Jason Huck a écrit :
>
>>
>> http://devblog.jasonhuck.com/2008/09/23/an-asset-management-system-for-lasso-powered-sites/
>
> I wanted to use your asset system but still had no time to implement it
> Jason
> Will it be able to run under Lasso 9 (with syntax changes perhaps)?
>
> Dominique
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>
>



--
tagSwap.net :: Open Source Lasso Code
<http://tagSwap.net/>

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


12