?
avatar dgt41
dgt41
23 May 2017

Times are changing, we should as well

So Joomla 4 will have some help from node, particularly from Grunt, to manage the static files (call me css, images and javascript scripts). As is right now the Grunt script reads the source javascript file from a folder and minifies it in the same folder. This was our first (you can call it baby step) to node tools, it is improving every day and we are happy with that.

BUT we can do even better!
So, the minifying script has the ability to create source maps, which are supported by all the browsers that Joomla 4 will support, and that make me wonder why do we have to ship both the minified and the plain file when we have the ability to cut down the size of the deliverable (I haven't check the actual benefit, but it should be some MBs).

To the point:

  • The idea is to have a root folder named src or media-src or something similar that will hold the source scripts.
  • The Grunt script will create only the minified script in the media and will also create a source map file.
  • The unmidnifyied scripts will not be included in the deliverable package!!

Pros

  • Setup the will serve us for the next years (call me ES6)
  • Less files, smaller packages
  • Debugging scripts doesn't need to enable the debug option in the configuration!

Cons

  • The contributors have to follow a different path (debug on their browser, but commit the changes to the source folder, nothing too fancy if you can edit a javascript file, I guess)
avatar dgt41 dgt41 - open - 23 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 23 May 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 23 May 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 24 May 2017
Category Feature Request JavaScript
avatar Fedik
Fedik - comment - 24 May 2017

Not sure.
I prefer to have a source file, to be able check something there quickly, while writing something based on "this" script. Sometimes it faster than googling for the doc for an actual version.
And the map file will be useless here.

avatar dneukirchen
dneukirchen - comment - 24 May 2017

? I dont need the source files when i have maps. It will improve client-side debugging, when implemented correctly ;-)

avatar yvesh
yvesh - comment - 24 May 2017

+1 when you have the source maps all is good

avatar yvesh
yvesh - comment - 24 May 2017

I prefer to have a source file, to be able check something there quickly, while writing something based on "this" script

@Fedik There is also a nice method in most debuggers / browsers -> {} <- to expand the source code

avatar Bakual
Bakual - comment - 24 May 2017

According to the compile-js command you will save ~3 MB in J4 if you don't ship the uncompressed files.
The full 3.7.2 package (as well as the nightly 4.0) is around 12,5 MB.
Honestly, the argument of shipping a smaller file is a moot point. It just doesn't matter if that zip is 10 or 13 MB big.
Shipping class map files of course is fine as they help debugging for those knowing how to use them. But imho it's not worth removing the uncompressed files from the shipped package.

avatar Fedik
Fedik - comment - 24 May 2017

@yvesh not really helpful, I am not about client side debugging (it another topic), I am about writing the code for "xx" extension.

For now I can just open source file, and check what I need, with all "dev" comments and so on.
When source file will be removed, then I should OR restore source from map/min version, OR use browser dev tools. Which consume more time.

If chose between size and time, I would chose the time.

And about debugging. Most of Joomla users have no clue what is JavaScript ?
So:

Debugging scripts doesn't need to enable the debug option in the configuration!

it is also drawback. For average user (who got some bug) will be harder to explain, how to correctly post the issue. Because all he can do, it to post an error like "Error: Undefined variable at line 1".

ups: Joomla! is Open Source, we should not hide the source :neckbeard:

avatar brianteeman
brianteeman - comment - 24 May 2017

I can't find the joomla4 browser requirements but are you sure that all supported browsers support using classmaps and especially does the browser support using classmaps without having to enable some hidden developer tool

avatar dgt41
dgt41 - comment - 24 May 2017

But imho it's not worth removing the uncompressed files from the shipped package.

That is one of the benefits here, but not the only one

@Fedik we have to think a bit for the future here ES6 is coming upon us

@brianteeman IE11, Edge and the latest 2 versions of all the other major browsers (all support source maps)

  • Internet Explorer 11, August 2014 update (version 11.0.9600.17239) or even better, the developer channel version: devchannel.modern.ie supporting the Gamepad API. A side note on IE: Microsoft is working on a new browser, Microsoft Edge, so be sure to check the latest web standards support for it.
  • Chrome 38 developer channel (version 38.0.2125.8 dev-m) / Opera 23.
  • Firefox 31 or Firefox 34 Nightly.
avatar brianteeman
brianteeman - comment - 24 May 2017

without having to enable some hidden developer tool
??

avatar dgt41
dgt41 - comment - 24 May 2017

without having to enable some hidden developer tool

Well in order to do any debugging client side you will have to use the hidden browser tools, so I really don't understand the question here

avatar brianteeman
brianteeman - comment - 24 May 2017

i give up

avatar Bakual
Bakual - comment - 24 May 2017

That is one of the benefits here, but not the only one

@dgt41 As far as I see, that's the only benefit with not shipping the files. The other benefits (shipping class maps files) can be done regardless of shipping the uncompressed ones. Or do I miss something here? Does shipping the uncompressed files somehow hinder "the future" of anything.

avatar dgt41
dgt41 - comment - 24 May 2017

The other benefits (shipping class maps files) can be done regardless of shipping the uncompressed ones

Absolutely true!

Does shipping the uncompressed files somehow hinder "the future" of anything

Well, if we wanted to push the boundaries we could convert the source files to ES6 and then transpile them back to ES5 (because we need to support IE11 and IE11 is not supporting ES6).
Of course this needs some consideration (do we want to move fast, or have a slower adoption pace), but at some point (1-2-3 years, when IE11 will be dead) ES6 will be the common ground in the JS landscape. So in that context having an agreement on the foundations will be a good starting point.
Hope this comment makes some sense

avatar Fedik
Fedik - comment - 24 May 2017

does the browser support using classmaps without having to enable some hidden developer tool

not really, by default browser do not care about classmaps files, it do not required for work,
the browser request for the map file only when the developer tool is enabled,

so even IE6 will not fail ?

avatar Fedik
Fedik - comment - 24 May 2017

@dgt41 I think we need to keep the source, it cost nothing

avatar dgt41
dgt41 - comment - 24 May 2017

@Fedik I think the big question that we need to answer sooner or later is ES6 and especially the dependency resolving (import/export modules).
So if there are people against this I can close it, np.

avatar Fedik
Fedik - comment - 24 May 2017

@dgt41 this is more related to #12402 ?
I have some thoughts about, I will try to sum them up, and write. But a bit later ?

avatar Bakual
Bakual - comment - 24 May 2017

(1-2-3 years, when IE11 will be dead)

IE11 will be supported until the EOL of Windows 10. And Windows 10 will be supported until October 2025. So it has a few more years to live ?

avatar dgt41
dgt41 - comment - 24 May 2017

@Bakual isn't Edge the default browser of Windows 10?

avatar Bakual
Bakual - comment - 24 May 2017

They both are included in Windows 10. Edge is the default browser but IE11 is there as well.
IE11 is the last version of IE and will be supported until EOL of Windows 10.

avatar dgt41 dgt41 - change - 24 May 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-05-24 14:32:17
Closed_By dgt41
avatar dgt41 dgt41 - close - 24 May 2017

Add a Comment

Login with GitHub to post a comment