Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
Compresssing Error Unexpected character `

I have some jQuery and JavaScript and when I try to compress the JavaScript I get an error saying Unexpected character '`'

I tried two JavaScript compressors but both gave me the same error

I don't know what is the cause of my error:
I don't know what is the cause of my error

Here is my code:

// Login Form Sumbission
$("#loginForm").submit(function (event){

    $("#loginButton").prop("disabled", true);
    $("#loginButton").html(`<div class="spinner-border text-light spinner-border-sm" role="status"><span class="visually-hidden">Loading...</span></div> Submit`);
    $("#loginEmail").off("input")
    $("#loginPassword").off("input")

    let formData = {
        "csrfmiddlewaretoken": $('#loginForm input[name=csrfmiddlewaretoken]').val(),
        "email": $("#loginEmail").val(),
        "password": $("#loginPassword").val(),
    };

    $.ajax({
        type: "POST",
        url: "/accounts/login/",
        data: formData,
        dataType: "json",
        encode: true,
    }).done(function (data){
        var status = data["status"];

        // If The User Successfully Logged In
        if (status === "success"){

            // Update Navigation Bar
            $("#navbar").replaceWith(data["navbarHtml"]);
            $("#loginModal button.btn-close").click();
            $("#modals").remove();

            // Update Other Things On The Web Page Base On Thier Path
            let path = window.location.pathname;

            if (path in data){
                var updateData = data[path]
            }
            else{
                var updateData = {}
            };

            for (item in updateData) {
                $(item).replaceWith(updateData[item]);             
            };

            $("#messages").html(`
            <div style="margin-bottom: 0px" class="alert alert-success alert-dismissible fade show" role="alert" id="messages">
                <strong class="text-dark">${data["message"]}</strong>
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>`)

        };
    });

    event.preventDefault();
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The error Unexpected character '`' is from the parser of the compressor.

I can't say for sure from which one (the site uses UglifyJS 2 and YUI) but I would guess it is YUI (its development has stopped several years ago).

YUI will fail to parse and compress modern JavaScript, it does not know about let and const, does not know `, await/async, …

So the solution will be to limit yourself to the features the compressor knows or to use a compressor that knows the features you use.

Which one to choose is out of the scope of StackOverflow (Terser, UglifyJS 3 and Google Closure Compiler are possible candidates all with their pros and cons)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda