Announcement

Collapse
No announcement yet.

Re-compressing the JavaScript files after editing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Re-compressing the JavaScript files after editing

    SellerDeck added compressed JavaScript with SellerDeck 2014. This brings multiple JavaScript files into a single compressed file, saving download time.

    The original JavaScript files are still available in the site and can be modified to implement non-standard functionality. However, if this is done then SellerDeck will upload the uncompressed original files (see the layout 'Standard Javascript Header Functions' for how this is done).

    The compressed JavaScript file is called 'sellerdeck.min.js' and it contains compressed, or minified, code from actiniccore.js, actinicextras.js, actinicsearch.js, dynamic.js, recentproductssupport.js and responsive.js.

    SellerDeck software does not feature a built-in JavaScript compressor as once compressed, as a rule the JavaScript files do not need to be recompressed.

    It is possible to re-compress the files after editing by installing a compressor and following the instructions below.

    The compressor of choice is 'Uglify', which is also used by jQuery; currently the best compressor available.

    Installing Uglify is fairly easy; the batch files to compress our files are installed as standard in the site folder. The intention was that any designers modifying the scripts would be fairly competent and can easily re-compress them prior to shipping to the customer.

    To install Uglify:

    1. install 'node.js' using the Windows installer at:-

    https://nodejs.org/en/download/

    This should set up paths so that 'node.js' can be run from the command line.

    NOTE: If that doesn't happen you may need to reboot.

    2. Open a cmd command prompt and enter

    npm install uglify-js@2 -g

    and press return.

    If this doesn't run you may have to change to the folder C:\Program Files (x86)\nodejs and run it directly from there.

    There is a batch file to create a compressed sellerdeck.min.js in the site folder called:-

    create_sellerdeck_min_pause.bat

    Whenever the standard JavaScript has been changed run this batch file to recreate the sellerdeck.min.js file.

    NOTE: If there is an error when running the batch file in the site, it's possible that you need to restart your computer so that uglify will work.

    If you receive an error message: -

    C:\Windows\system32>call create_sellerdeck_min.bat
    'create_sellerdeck_min.bat' is not recognized as an internal or external command operable program or batch file.

    C:\Windows\system32>pause
    Press any key to continue . . .

    Even when running as 'Administrator', this is because Windows is running the process in the 'System32' folder instead of the local directory.

    This can be resolved by copying the file 'create_sellerdeck_min_pause.bat' and adding the line: -

    Code:
    chdir %~dp0
    to the top of that file and saving it, then using this file when you edit the JavaScript files.

    Note also that .map files are created and can be used by the debugger in Chrome.

    For more information see http://www.elijahmanor.com/the-magic...-9-source-map/ . The jQuery map file has been included as standard as well as the uncompressed jQuery file.

    If you are adding more JavaScript files then they can be added to the batch file and to sellerdeck.min.js; or you could compress them separately.

    NOTE: It is your responsibility to ensure how safe the files are, as this procedure and the consequences would not be supported by SellerDeck.

    You will find default copies of all the files within the folder 'Original' that in version 14 sits under 'SellerDeck 2014' folder within the 'Program Files\Program Files (x86)' folder.
    In version 16 it is in 'SellerDeck 2016\Versioned' beneath a folder named after the version i.e. '16.0.7.0.0.0.UJOD'.
    In version 18 it is in 'ProgramData\Sellerdeck\Sellerdeck v18\Versioned beneath a folder named after the version i.e. '18.0.5.0.0.0.UJOC'.
    Last edited by G.W.Green; 03-Nov-2020, 09:38 AM.
Working...
X