WAHtmlRoot>>writeHeadOn: changed

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

WAHtmlRoot>>writeHeadOn: changed

Martial Boniou
Hi,

Between Seaside2.8a1-lr.220 (and previous) and the latest Seaside (317)
there is a big change in the order in the head attributes writing. As a
webmaster I think it's a bad order. The 2 last lines:

#writeHeadOn: aDocument
        aDocument nextPutAll: docType.
        aDocument openTag: 'html' attributes: htmlAttrs.
        aDocument openTag: 'head' attributes: headAttrs.
        self writeElementsOn: aDocument.
        self writeScriptsOn: aDocument.
        self writeStylesOn: aDocument. (...)

should become:
        self writeStylesOn: aDocument.
        self writeScriptsOn: aDocument.

because you can load CSS files through javascripts. For example, as
XHTML1.1 deprecated <noscript>, it's becoming a common way to load first
a global CSS (for non-javascript browsers or for those who disable it
(for more security in an intranet framework)) and then, to load a
special CSS with javascript:

var style=document.createElement("link");
style.setAttribute("rel", "stylesheet");
style.setAttribute("type", "text/css");
style.setAttribute("href", "/seaside/wafiles/special.css");
style.setAttribute("media", "screen");

to be sure that this special CSS might be loaded only if javascript is
enabled.

So this must be a good idea to restore this original order (it was done
like that in the previous version of Seaside).

Cheers,

--
Martial

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAHtmlRoot>>writeHeadOn: changed

Lukas Renggli
> Between Seaside2.8a1-lr.220 (and previous) and the latest Seaside (317)
> there is a big change in the order in the head attributes writing.

Not just the order. The responsibilities of these objects has been
changed a bit, for example WAHtmlRoot now also closes the XHTML
document not just opens it ...

> So this must be a good idea to restore this original order (it was done
> like that in the previous version of Seaside).

Thanks for pointing this issue out. I didn't thought of that, because
I usually don't use #writeStylesOn: and #writeScriptsOn:.
Seaside2.8a1-lr.322 reorders the elements like this:

        self writeStylesOn: aDocument.
        self writeScriptsOn: aDocument.
        self writeElementsOn: aDocument.

I put #writeElementsOn: at the last position. I think this makes more
sense, but I don't know how this was handled before?

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAHtmlRoot>>writeHeadOn: changed

Avi Bryant-2
On 5/16/07, Lukas Renggli <[hidden email]> wrote:

> Thanks for pointing this issue out. I didn't thought of that, because
> I usually don't use #writeStylesOn: and #writeScriptsOn:.
> Seaside2.8a1-lr.322 reorders the elements like this:
>
>         self writeStylesOn: aDocument.
>         self writeScriptsOn: aDocument.
>         self writeElementsOn: aDocument.
>
> I put #writeElementsOn: at the last position. I think this makes more
> sense, but I don't know how this was handled before?

I think elements should be in the first position - that way you end up
with the external scripts and styles first, and the inline scripts and
styles (which may reference or override stuff in the external files)
second.

Avi
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAHtmlRoot>>writeHeadOn: changed

Martial Boniou
In reply to this post by Lukas Renggli
On Wed, 2007-05-16 at 20:48 +0200, Lukas Renggli wrote:
> > Between Seaside2.8a1-lr.220 (and previous) and the latest Seaside (317)
> > there is a big change in the order in the head attributes writing.
>
> Not just the order. The responsibilities of these objects has been
> changed a bit, for example WAHtmlRoot now also closes the XHTML
> document not just opens it ...

Yes and it makes more sense.

> > So this must be a good idea to restore this original order (it was done
> > like that in the previous version of Seaside).
>
> Thanks for pointing this issue out. I didn't thought of that, because
> I usually don't use #writeStylesOn: and #writeScriptsOn:.
> Seaside2.8a1-lr.322 reorders the elements like this:
>
> self writeStylesOn: aDocument.
> self writeScriptsOn: aDocument.
> self writeElementsOn: aDocument.

> I put #writeElementsOn: at the last position. I think this makes more
> sense, but I don't know how this was handled before?

Thanks. Actually I don't know good tools for javascript so I prefer to
test with firebug and type in #style:, #script: and WAFileLibrary during
the dev phase to export everything in a bundle. For deployment I use
Apache as you do.

For the last #writeElementsOn: message, I think it's better to have it
before all. I sampled the previous version's method:

#writeHeadOn: aStream
        aStream nextPutAll: '<title>', title, '</title>'.
        headElements do: [:ea | ea writeOn: aStream].
        styles do: [:ea | self writeStyle: ea on: aStream].
        scripts do: [:ea | self writeScript: ea on: aStream].

The idea (and I think it could be confirmed) is: "javascript should load
in the latest lines of the head because scripts can shortcut everything"

Cheers,

--
Martial

> Cheers,
> Lukas
>

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: WAHtmlRoot>>writeHeadOn: changed

Lukas Renggli
> #writeHeadOn: aStream
>         aStream nextPutAll: '<title>', title, '</title>'.
>         headElements do: [:ea | ea writeOn: aStream].
>         styles do: [:ea | self writeStyle: ea on: aStream].
>         scripts do: [:ea | self writeScript: ea on: aStream].
>
> The idea (and I think it could be confirmed) is: "javascript should load
> in the latest lines of the head because scripts can shortcut everything"

Allright, the latest version published does exactly this.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside