perf: delay heavy JS initializations to reduce main-thread work
This commit is contained in:
@@ -51,6 +51,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
/* Delay heavy initializations to improve TBT and Main Thread work */
|
||||
setTimeout(function() {
|
||||
/* Hero Slider Layout JS */
|
||||
const hero_slider_layout = new Swiper('.hero-slider-layout .swiper', {
|
||||
slidesPerView : 1,
|
||||
@@ -166,16 +168,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
/* Youtube Background Video JS */
|
||||
if ($('#herovideo').length) {
|
||||
var myPlayer = $("#herovideo").YTPlayer();
|
||||
}
|
||||
|
||||
/* Init Counter */
|
||||
if ($('.counter').length) {
|
||||
$('.counter').counterUp({ delay: 6, time: 3000 });
|
||||
}
|
||||
|
||||
/* Image Reveal Animation */
|
||||
if ($('.reveal').length) {
|
||||
gsap.registerPlugin(ScrollTrigger);
|
||||
@@ -281,9 +273,9 @@
|
||||
|
||||
/* Parallaxie js */
|
||||
var $parallaxie = $('.parallaxie');
|
||||
if($parallaxie.length && ($window.width() > 991))
|
||||
if($parallaxie.length && ($(window).width() > 991))
|
||||
{
|
||||
if ($window.width() > 768) {
|
||||
if ($(window).width() > 768) {
|
||||
$parallaxie.parallaxie({
|
||||
speed: 0.55,
|
||||
offset: 0,
|
||||
@@ -291,6 +283,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Animated Wow Js */
|
||||
new WOW().init();
|
||||
|
||||
/* Youtube Background Video JS */
|
||||
if ($('#herovideo').length) {
|
||||
var myPlayer = $("#herovideo").YTPlayer();
|
||||
}
|
||||
|
||||
}, 100);
|
||||
|
||||
/* Init Counter (Keep this faster or outside if needed) */
|
||||
if ($('.counter').length) {
|
||||
$('.counter').counterUp({ delay: 6, time: 3000 });
|
||||
}
|
||||
|
||||
/* Zoom Gallery screenshot */
|
||||
$('.gallery-items').magnificPopup({
|
||||
delegate: 'a',
|
||||
@@ -315,12 +322,14 @@
|
||||
|
||||
/* Contact form validation */
|
||||
var $contactform = $("#contactForm");
|
||||
if($contactform.length) {
|
||||
$contactform.validator({focus: false}).on("submit", function (event) {
|
||||
if (!event.isDefaultPrevented()) {
|
||||
event.preventDefault();
|
||||
submitForm();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function submitForm(){
|
||||
/* Ajax call to submit form */
|
||||
@@ -351,16 +360,17 @@
|
||||
}
|
||||
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
|
||||
}
|
||||
/* Contact form validation end */
|
||||
|
||||
/* Appointment form validation */
|
||||
var $appointmentForm = $("#appointmentForm");
|
||||
if($appointmentForm.length) {
|
||||
$appointmentForm.validator({focus: false}).on("submit", function (event) {
|
||||
if (!event.isDefaultPrevented()) {
|
||||
event.preventDefault();
|
||||
submitappointmentForm();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function submitappointmentForm(){
|
||||
/* Ajax call to submit form */
|
||||
@@ -391,10 +401,6 @@
|
||||
}
|
||||
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
|
||||
}
|
||||
/* Appointment form validation end */
|
||||
|
||||
/* Animated Wow Js */
|
||||
new WOW().init();
|
||||
|
||||
/* Popup Video */
|
||||
if ($('.popup-video').length) {
|
||||
|
||||
Reference in New Issue
Block a user