django-pipeline icon indicating copy to clipboard operation
django-pipeline copied to clipboard

pipeline compression skips over js when using yuglify

Open esskaey opened this issue 3 years ago • 2 comments

Hi there,

I am a bit new to using js. I am having a strange output, where the functions inside a js file are being skipped over during compression using yuglify. I am getting no errors, except when checking the output the functions are not present!

The file which is being ignored

// application.js
function changeValueProp() {
    if (document.getElementById('ShowHideProp').value == 'Show Properties'){
      document.getElementById('ShowHideProp').value = 'Hide Properties';
    }
    else{
      document.getElementById('ShowHideProp').value = 'Show Properties';
    }
  }

In my pipeline config I am using

{
    "JAVASCRIPT": {
     "application": {"source_filenames":  (f'{APP_STATIC_DIR}/application.js',f'{APP_STATIC_DIR}/application01.js',),
                             "output_filename":    'compressed/js/application.js'},
                          },
    "YUGLIFY_BINARY": f"{BASE}/node_modules/yuglify/bin/yuglify",
}

I just checked that if I use "DISABLE_WRAPPER":True, the function from application.js is compressed and put in the output file. In ReadTheDocs, the DISABLE_WRAPPER:False is recommended for improving performance.

Is it possible to use the wrapper without it skipping over the js described above ?

BR

SK

esskaey avatar Jul 13 '22 14:07 esskaey

I think it's because yuglify skips functions that aren't used in your code. It's better to take a look at yuglify documentation.

peymanslh avatar Feb 25 '23 13:02 peymanslh