Page 1 of 1

[2.0] Inline JS

Posted: Sun Jan 02, 2011 9:48 pm
by garvinhicking
discussion here

Re: [2.0] Inline JS

Posted: Mon Jan 17, 2011 12:46 pm
by yellowled
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

Re: [2.0] Inline JS

Posted: Tue Jun 25, 2013 6:40 pm
by onli
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.

Re: [2.0] Inline JS

Posted: Tue Jun 25, 2013 8:08 pm
by yellowled
onli wrote:Sounds like a good idea? Suggestions, remarks?
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.

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

Re: [2.0] Inline JS

Posted: Wed Jun 26, 2013 11:20 am
by garvinhicking
Hi!

This new hook is so simple, I'm afraid I wonder why it was'nt there in first place. Great idea. :-)

Regards,
Garvin

Re: [2.0] Inline JS

Posted: Wed Jun 26, 2013 12:38 pm
by onli
Thanks Garvin :)
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)
That should be easily patchable, the user.css I mean.
yellowled wrote:* have the core minify the dynamically generated CSS and JS files (I guess you already thought of that, as well)
We should try that. But maybe as an option, and measuring whether minifying and sending then is really faster than just sending.

Re: [2.0] Inline JS

Posted: Wed Jun 26, 2013 1:36 pm
by yellowled
onli wrote:That should be easily patchable, the user.css I mean.
I'm not sure a user.js would really be necessary for 98% of users, so that's not that important.
onli wrote:But maybe as an option, and measuring whether minifying and sending then is really faster than just sending.
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.

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

Posted: Wed Jun 26, 2013 1:44 pm
by onli
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.

Re: [2.0] Inline JS

Posted: Mon Jul 29, 2013 3:28 pm
by mattsches
Couldn't we cache the minified file?

Re: [2.0] Inline JS

Posted: Mon Jul 29, 2013 6:13 pm
by onli
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.