madskristensen / BundlerMinifier

Visual Studio extension
Other
616 stars 172 forks source link

Issue with minified js file #596

Open brambuz opened 1 year ago

brambuz commented 1 year ago

Describe the bug I have a JS file with "$(document).ready(function ()" and other functions, bundleconfig.json is:

....
  {
    "outputFileName": "wwwroot/bundles/Scripts/Shared/header.min.js",
    "inputFiles": [
      "wwwroot/Scripts/Shared/_header.js"
    ],
    "minify": {
      "enabled": true,
      "renameLocals": true
    },
    "sourceMap": false
  }
.... 

but in the output file missing all "$(document).ready(function ()" file start with first function (see screenshot)

Visual Studio Community 2022 Version 17.5.3 Bundler and Minifier ver 2.9.9

Expected behavior min file with all part of original js file

Screenshots original file JS:

full

min file:

min_issue

thank you for your help

pitus commented 1 year ago

Can you post the minified source code? I suspect that your $(document).ready(function () ... ) was optimized into a shorthand version like $($ => ...) or $(function($)...) so your search fails. See https://stackoverflow.com/questions/6004129/document-ready-shorthand