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 */
|
/* Hero Slider Layout JS */
|
||||||
const hero_slider_layout = new Swiper('.hero-slider-layout .swiper', {
|
const hero_slider_layout = new Swiper('.hero-slider-layout .swiper', {
|
||||||
slidesPerView : 1,
|
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 */
|
/* Image Reveal Animation */
|
||||||
if ($('.reveal').length) {
|
if ($('.reveal').length) {
|
||||||
gsap.registerPlugin(ScrollTrigger);
|
gsap.registerPlugin(ScrollTrigger);
|
||||||
@@ -281,9 +273,9 @@
|
|||||||
|
|
||||||
/* Parallaxie js */
|
/* Parallaxie js */
|
||||||
var $parallaxie = $('.parallaxie');
|
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({
|
$parallaxie.parallaxie({
|
||||||
speed: 0.55,
|
speed: 0.55,
|
||||||
offset: 0,
|
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 */
|
/* Zoom Gallery screenshot */
|
||||||
$('.gallery-items').magnificPopup({
|
$('.gallery-items').magnificPopup({
|
||||||
delegate: 'a',
|
delegate: 'a',
|
||||||
@@ -315,12 +322,14 @@
|
|||||||
|
|
||||||
/* Contact form validation */
|
/* Contact form validation */
|
||||||
var $contactform = $("#contactForm");
|
var $contactform = $("#contactForm");
|
||||||
|
if($contactform.length) {
|
||||||
$contactform.validator({focus: false}).on("submit", function (event) {
|
$contactform.validator({focus: false}).on("submit", function (event) {
|
||||||
if (!event.isDefaultPrevented()) {
|
if (!event.isDefaultPrevented()) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
submitForm();
|
submitForm();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function submitForm(){
|
function submitForm(){
|
||||||
/* Ajax call to submit form */
|
/* Ajax call to submit form */
|
||||||
@@ -351,16 +360,17 @@
|
|||||||
}
|
}
|
||||||
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
|
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
|
||||||
}
|
}
|
||||||
/* Contact form validation end */
|
|
||||||
|
|
||||||
/* Appointment form validation */
|
/* Appointment form validation */
|
||||||
var $appointmentForm = $("#appointmentForm");
|
var $appointmentForm = $("#appointmentForm");
|
||||||
|
if($appointmentForm.length) {
|
||||||
$appointmentForm.validator({focus: false}).on("submit", function (event) {
|
$appointmentForm.validator({focus: false}).on("submit", function (event) {
|
||||||
if (!event.isDefaultPrevented()) {
|
if (!event.isDefaultPrevented()) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
submitappointmentForm();
|
submitappointmentForm();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function submitappointmentForm(){
|
function submitappointmentForm(){
|
||||||
/* Ajax call to submit form */
|
/* Ajax call to submit form */
|
||||||
@@ -391,10 +401,6 @@
|
|||||||
}
|
}
|
||||||
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
|
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
|
||||||
}
|
}
|
||||||
/* Appointment form validation end */
|
|
||||||
|
|
||||||
/* Animated Wow Js */
|
|
||||||
new WOW().init();
|
|
||||||
|
|
||||||
/* Popup Video */
|
/* Popup Video */
|
||||||
if ($('.popup-video').length) {
|
if ($('.popup-video').length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user