Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript function with async gets ignored #25

Open
danieljurican opened this issue Feb 15, 2021 · 4 comments
Open

Javascript function with async gets ignored #25

danieljurican opened this issue Feb 15, 2021 · 4 comments

Comments

@danieljurican
Copy link

Hi.
I am having problem with minified js files,...
When I use javascript function like below (calling async), it gets ignored by SquishIt. Function is missing from minified version. I am using version 1.0.4 (same is with version 0.9).

example 1:

async function postData(url = '', data = {}) {           
          const response = await fetch(url, {
              method: 'POST', // *GET, POST, PUT, DELETE, etc.
              mode: 'cors', // no-cors, *cors, same-origin
              cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
              credentials: 'same-origin', // include, *same-origin, omit
              headers: {
                  'Content-Type': 'application/json'
                  // 'Content-Type': 'application/x-www-form-urlencoded',
              },
              redirect: 'follow', // manual, *follow, error
              referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
              body: JSON.stringify(data) // body data type must match "Content-Type" header
          });
          return response.json(); // parses JSON response into native JavaScript objects
      }

example 2:


function sweetAlertOpen() {
    (async () => {

        const { value: formValues } = await Swal.fire({
            title: 'Sweetalert title....',
            type: 'info',
...
@AlexCuse
Copy link
Owner

This is usually an issue with the minifier itself. If you are using the default (MS ajax) you can try using it with yahoo with something like:

Configuration.Apply(iso => iso.DefaultMinifier = new Minifiers.Javascript.YUIMinifier())

or similar. I am not really doing much .net stuff lately but if this doesn't help I can probably get set up in a couple days. You can look at the configuration options available to either minifier as well - maybe just need to set them up to allow async or something. If you find anything about a minimum version of ajax min or yui I will look into what we can do here to support it as well.

Out of curiosity what asp.net etc versions are you using?

@AlexCuse
Copy link
Owner

(do the above in your startup pipeline somewhere, you can also change at the bundle level using .WithMinifier method)

@danieljurican
Copy link
Author

danieljurican commented Feb 16, 2021

I am working on
ASP.NET 4 (Web forms project, VB.NET)

Where exactly should I put WithMinifier method,...
I am using bundle now with line:
Bundle.JavaScript().RenderNamed("combojs")

EDIT:
I think I found solution:
Bundle.JavaScript().WithMinifier(Of Minifiers.JavaScript.YuiMinifier).RenderNamed("combojs")

@AlexCuse
Copy link
Owner

Sorry for the late reply - I could have sworn I sent before. I think this is right but I don't really know VB.net.

I assume this worked for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants