Opened 14 years ago

Closed 11 years ago

#10 closed defect (fixed)

Clean & Compress code

Reported by: gogo Owned by: gogo
Priority: normal Milestone: Version 1.0
Component: Xinha Core Version: trunk
Severity: normal Keywords:

Description (last modified by gogo)

The current codebase is pretty dirty and somewhat bloated.

I have tried a javascript compressor and it's possible to compress down to about 1/2 the current size in it's current state.

I'd like to separate functionality a bit so that functions could be loaded as they are needed to further reduce the initial load overhead.

Change History (15)

comment:1 Changed 14 years ago by anonymous

An obvious target is to handle localization serverside, and get rid of the buggy translation javascript that users shouldn't have to download.

comment:2 Changed 14 years ago by gogo

  • Description modified (diff)

No that's a bad idea. For one, developers would then have to have a "supported" programming language on hand. Nothing "core" should require a server language. Niko's changes to the I18n system fix the problems with localisations getting out of date.

comment:3 Changed 13 years ago by gogo

  • Milestone set to 2.0
  • Version set to trunk

comment:4 Changed 12 years ago by ray

  • Milestone changed from 2.0 to Version 1.0

So here we go:

  1. separated functions that were only for one browser, like handling of selections and DOM stuff into browser specific files
  2. separated the functions HTMLArea.prototype._createLink (),HTMLArea.prototype._insertImage(), and HTMLArea.getHTML (), which are replaced by plugins

This saves if you use Mozilla without plugins around 4k, IE without plugins 13k and Mozilla with EFM, Linker, and GetHtml 19k

This is not all too much but better than wasting bandwidth :)

Added dojo javascript compressor which seems reliable and effective
It can be found in the contrib folder. I have also added a batch file that can be used to batch convert files by drag&drop

When experimenting with the compressor I encountered a problem in linker.js where an object property inside an evaluation failed, but a simple variable worked. Caution seems to be advisable.

Over there is saving of ca. 50% with compressed code.

comment:5 Changed 12 years ago by ray

committed this in rev [635] but unfortunately failed to add a comment

comment:6 Changed 12 years ago by mokhet

Just a self-note to make me remember to synchronize the branch I'm working on with this major update (I have a lot to commit but so little time to do it correctly so I'll do it at time, without rushing :)

Good luck Ray for this update, it has to be done soon or later. Sooner is usually good even if I would recognize this looks like a VERY scary update to me :)

comment:7 Changed 12 years ago by ray

moved loading of color_picker.js in HTMLArea.prototype._colorSelector()

This makes up for an additional saving of 29k

comment:8 Changed 12 years ago by gogo

See changeset:672 for some modifications to code separation.

comment:9 Changed 12 years ago by gogo

changeset:674 has some more work on this

comment:10 Changed 12 years ago by ray

changeset: 688 in short:

created a new folder "modules"
It is thought to hold all the functional parts that are not plugins, that is that are needed to run the basic editor. This includes:

  • FullScreen? from the plugins folder
  • the diverse dialog implementations moved from the root folder; popupwin.js is now loaded from TableOperations? plugin
  • the browser specific plugins (modules/Gecko/Gecko.js & modules/InternetExplorer/InternetExplorer.js)
  • InsertImage?, InsertTable?, CreateLinks? moved from the popups folder; implemented as plugins; loaded depending if respective button is in toolbar
  • the color picker moved from the popups folder
  • dom_checkInsertP (mozParaHandler = dirty, see #918) & EnterParagraphs? plugin implemented as alternative plugins (modules/Gecko/paraHandlerDirty.js & modules/Gecko/paraHandlerBest.js)
  • GetHtml? plugin & "old" getHTML implemented as alternative plugins depending on new config option xinha_config.getHtmlMethod = 'DOMwalk' or 'TransformInnerHTML'; the GetHtml? plugin now merely sets getHtmlMethod = 'TransformInnerHTML'

I know this is a big change, but IMHO it's healthy to have a clear structure

comment:11 Changed 12 years ago by gogo

Ray, I think you are not moving the files correctly and we have lost version history now for the new file locations/names.

Please when you copy or move a file be sure that you do it using Subversion, do not simply copy the file to a new location, add it, and delete the old one, you must use "svn cp" or "svn mv" if you use the command line tools, or consult the documentation for whatever subversion interface you have for the correct method of copying, moving or renaming files in the repository.

If you do not use subversion to do the move/copy it will not know that for example modules/Gecko/Gecko.js used to be functionsMozilla.js

comment:12 Changed 12 years ago by ray

Umm, sorry, I was aware of the problem, but being a lame windows user I didn't see such a function in TortoiseSVN...

But what do you think about the change itself? Do you approve? I'd like to do another release soon, as there's quite a heap of bugfixes already

comment:13 Changed 12 years ago by ray

Umm, sorry, I was aware of the problem, but being a lame windows user I didn't see such a function in TortoiseSVN...

But what do you think about the change itself? Do you approve? I'd like to do another release soon, as there's quite a heap of bugfixes already

comment:14 Changed 12 years ago by gogo

The changes themselves look fine. All the changes might need some more testing before a release though?

I think for TortoiseSVN it's probably in the explorer context menu a special copy or rename option, or you use the repository browser? I don't have tortoise installed on an machines at the moment.

I fixed up the history for this one anyway (you did the same for htmlarea.js but I was too slow to fix that one up without lots of headaches really :)).

comment:15 Changed 11 years ago by ray

  • Resolution set to fixed
  • Status changed from new to closed

We can leave this open forever or just close it ;)

Note: See TracTickets for help on using tickets.