Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda