[2.0] Inline JS
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
[2.0] Inline JS
discussion here
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: [2.0] Inline JS
Some quick info: This is about trying to remove inline JS like i.e. onclick handlers as far as possible in order to seperate behaviour (JS) from structure (HTML). These should probably be replaced with jQuery statements, possibly in some kind of central file like jquery.s9y.core.functions.js or something.
YL
YL
Re: [2.0] Inline JS
I'd like to use this thread also for the discussion of the js-hook I implemented as a proposal.
Giving plugins the option to register for a "js"-event, it generates a serendipity.js which bundles all the javascript echoed into that event. It is basically the same mechanism as the css-hook, just that I didn't implement the admin-distinction yet, not knowing whether it would be needed. It makes it easier for plugins to use Javascript without inlining it and needing to use the external event-hook to serve an external js-file.
Sounds like a good idea? Suggestions, remarks?
PS: If you would like to discuss this in an own thread, just give me a hint or slice it.
Giving plugins the option to register for a "js"-event, it generates a serendipity.js which bundles all the javascript echoed into that event. It is basically the same mechanism as the css-hook, just that I didn't implement the admin-distinction yet, not knowing whether it would be needed. It makes it easier for plugins to use Javascript without inlining it and needing to use the external event-hook to serve an external js-file.
Sounds like a good idea? Suggestions, remarks?
PS: If you would like to discuss this in an own thread, just give me a hint or slice it.
Re: [2.0] Inline JS
This is one of the best 2.0 features so far. If we get all themes and plugins to “spit” their CSS/JS into these hooks, it will be great for performance optimization.onli wrote:Sounds like a good idea? Suggestions, remarks?
Ideas:
* a way to include user-generated CSS and JS into these (i.e. include 2k11's user.css in serendipity.css; the user.css is a beloved feature, but it is a performance hit)
* have the core minify the dynamically generated CSS and JS files (I guess you already thought of that, as well)
YL
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: [2.0] Inline JS
Hi!
This new hook is so simple, I'm afraid I wonder why it was'nt there in first place. Great idea.
Regards,
Garvin
This new hook is so simple, I'm afraid I wonder why it was'nt there in first place. Great idea.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: [2.0] Inline JS
Thanks Garvin :)
That should be easily patchable, the user.css I mean.yellowled wrote:* a way to include user-generated CSS and JS into these (i.e. include 2k11's user.css in serendipity.css; the user.css is a beloved feature, but it is a performance hit)
We should try that. But maybe as an option, and measuring whether minifying and sending then is really faster than just sending.yellowled wrote:* have the core minify the dynamically generated CSS and JS files (I guess you already thought of that, as well)
Re: [2.0] Inline JS
I'm not sure a user.js would really be necessary for 98% of users, so that's not that important.onli wrote:That should be easily patchable, the user.css I mean.
Minification will probably be tricky anyway because of the fact that at least some JS is now smartyfied and uses the new Smarty3 “delimiting by space” (or however it's called), which might be an issue with minifying.onli wrote:But maybe as an option, and measuring whether minifying and sending then is really faster than just sending.
However, minifying CSS/JS usually really has an effect. As an example: minifying the current new backend CSS saves 25% …
YL
Re: [2.0] Inline JS
Don't think that it would be tricky because of smarty. We should simply minify after smarty-execution on the generated JS.
Sure, that will have an effect. But 25% file-size-reduction is only good if on every call, minification takes less time than submitting a file 25% bigger. That is not guaranteed.
Sure, that will have an effect. But 25% file-size-reduction is only good if on every call, minification takes less time than submitting a file 25% bigger. That is not guaranteed.
Re: [2.0] Inline JS
Couldn't we cache the minified file?
Re: [2.0] Inline JS
The minified file would be cached by the browser, but that isn't what you mean, right?. Could we cache it on the side of s9y? I wouldn't know at which point and when to invalidate, given the variable replacement.