[2.0] Inline JS

Mark threads with "[2.0]" for discussions about features in the longer-term future, "[1.6]" is for short-term. This is not the place for general discussions or plugin or template requests. Only features that are approved to happen by the core team should be listed here for better structuring.
Locked
User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

[2.0] Inline JS

Post by garvinhicking » Sun Jan 02, 2011 10:48 pm

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/

User avatar
yellowled
Regular
Posts: 7079
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: [2.0] Inline JS

Post by yellowled » Mon Jan 17, 2011 1:46 pm

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
amazon Wishlist - Serendipity-Podcast (German only, sorry)

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: [2.0] Inline JS

Post by onli » Tue Jun 25, 2013 6:40 pm

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.

User avatar
yellowled
Regular
Posts: 7079
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: [2.0] Inline JS

Post by yellowled » Tue Jun 25, 2013 8:08 pm

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
amazon Wishlist - Serendipity-Podcast (German only, sorry)

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0] Inline JS

Post by garvinhicking » Wed Jun 26, 2013 11:20 am

Hi!

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/

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: [2.0] Inline JS

Post by onli » Wed Jun 26, 2013 12:38 pm

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.

User avatar
yellowled
Regular
Posts: 7079
Joined: Fri Jan 13, 2006 12:46 pm
Location: Eutin, Germany
Contact:

Re: [2.0] Inline JS

Post by yellowled » Wed Jun 26, 2013 1:36 pm

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
amazon Wishlist - Serendipity-Podcast (German only, sorry)

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: [2.0] Inline JS

Post by onli » Wed Jun 26, 2013 1:44 pm

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.

mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 10:35 pm
Location: Wiesbaden, Germany
Contact:

Re: [2.0] Inline JS

Post by mattsches » Mon Jul 29, 2013 3:28 pm

Couldn't we cache the minified file?

User avatar
onli
Regular
Posts: 2254
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: [2.0] Inline JS

Post by onli » Mon Jul 29, 2013 6:13 pm

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.

Locked