• Please refrain from assuming that jQuery is in use, especially when there isn’t much reason for it. For instance, the JS in the file “includes/class-ctn-load-time.php” on line 80, instead of the code:

    //ctn loadtime display
    (function($) {
        $(document).on('ready', function () {
            $('.ctn_load_time_in_sec').text(<?php echo $this->load_time; ?> + " seconds");
        });
    })(jQuery)

    It’s better to use vanilla js, which is also more elegant:

    //ctn loadtime display
    document.addEventListener('DOMContentLoaded', () => {
        let o = document.querySelector('.ctn_load_time_in_sec');
        o && (o.textContent = <?= $this->load_time ?? 'unknown' ?> seconds);
    });

    In any case, thank you for the plugin.

Viewing 1 replies (of 1 total)
  • Thread Starter cvladan

    (@cvladan)

    Also, in the nearby PHP code, within the same file, shouldn’t it be “endtime minus starttime” rather than the opposite? Specifically,

    $load_time = $this->starttime - $this->endtime;

    Shouldn’t it be changed to:

    $load_time = $this->endtime - $this->starttime;

    Right?

Viewing 1 replies (of 1 total)
  • The topic ‘Please, avoid jQuery’ is closed to new replies.