Minifying Javascript?

I’ve noticed that Javascript takes up a lot of space on pages and slows the page down drastically. Is there a way to cache my Javascript or any method to minimize its use on my pages?

The Javascript really shouldn’t slow down the page much - only if you have inefficient code, or a massive amount of code. There really is no way to minify the code, although you might be able to do some basic minifying of code in the Public folder.

Depending on what your code does, you could put it in the backend (server-side). You will have the “overhead” of calling backend code - that is, waiting for the Promise to be fulfilled. However, you will eliminate the need to load the Javascript into the browser page.

I have made some custom import/export onClick: links for some interactive boxes. Would I be able to put those in the back-end and still keep the links on the front-end?

@daniel53653 It really depends on what the code is. What sort of interactive boxes? Does it currently work now?

Keep in mind that WixCode understands all of Javascript, except for anything that accesses the DOM. This keeps the user from inadvertently “breaking” something. Accessing document elements such as div, span, button, etc is off-limits. The way to access elements on the page is only through $w.

Can Someone help me minify this or put it in the backend?

Its custom code for my menus, when you click a button, the strip hides, when you get out of the strip also. its simple but have never coded before, need to minify or put it in backend i guess.

The site is www.dargenta.com

$w.onReady( function () {
//TODO: write your page related code here…
});
import wixLocation from ‘wix-location’ ;
export function GiftsButton_mouseIn(event) {
$w( ‘#SculptureStrip’ ).hide();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).show();
$w( ‘#OurWorldStrip’ ).hide();
}
export function SculptureButton_mouseIn(event) {
$w( ‘#SculptureStrip’ ).show();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).hide();
}
export function OurWorld_mouseIn(event) {
$w( ‘#SculptureStrip’ ).hide();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).show();
}
export function HomeDecorButton_mouseIn(event) {
$w( ‘#SculptureStrip’ ).hide();
$w( ‘#HomeDecorStrip’ ).show();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).hide();
}

export function OurWorldStrip_mouseOut(event) {
$w( ‘#OurWorldStrip’ ).hide();
}
export function SculptureStrip_mouseOut(event) {
$w( ‘#SculptureStrip’ ).hide();
}
export function HomeDecorStrip_mouseOut(event) {
$w( ‘#HomeDecorStrip’ ).hide();
}
export function GiftsStrip_mouseOut(event) {
$w( ‘#GiftsStrip’ ).hide();
}
export function DargentaLogo_mouseIn(event) {
$w( ‘#SculptureStrip’ ).hide();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).hide();
}
export function SculptureButton_mouseIn_1(event) {
$w( ‘#SculptureStrip’ ).show();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).hide();
}
export function SculptureButton_click(event) {
wixLocation.to( “/home-decor-satue-collection” );
$w( ‘#SculptureStrip’ ).hide();
}
export function HomeDecorButton_click(event) {
wixLocation.to( “/home-decor-products-silver” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function GiftsButton_click(event) {
wixLocation.to( “/luxury-gifts” );
$w( ‘#GiftsStrip’ ).hide()
}
export function OurWorld_click(event) {
wixLocation.to( “/our-world-home-decor-statues” );
$w( ‘#OurWorldStrip’ ).hide();
}
export function BeautyCraftArtButton_click(event) {
wixLocation.to( “/beauty-craft-art-home-decor-statues” );
$w( ‘#OurWorldStrip’ ).hide();
}
export function DargentaCollectosButton_click(event) {
wixLocation.to( “/dargenta-members-club” );
$w( ‘#OurWorldStrip’ ).hide();
}
export function OurLegacyButton_click(event) {
wixLocation.to( “/our-legacy-in-home-decor” );
$w( ‘#OurWorldStrip’ ).hide();
}
export function OurSculptorsButton_click(event) {
wixLocation.to( “/dargenta-sculptors-home-decor” );
$w( ‘#OurWorldStrip’ ).hide();
}
export function AnimalArtButton_click(event) {
wixLocation.to( “/wildlife-collections” );
$w( ‘#SculptureStrip’ ).hide();
}
export function SkyAnimalsButton_click(event) {
wixLocation.to( “/bird-statue-collections” );
$w( ‘#SculptureStrip’ ).hide();
}
export function EarthAnimalButton_click(event) {
wixLocation.to( “/terrestrial-animal-collections” );
$w( ‘#SculptureStrip’ ).hide();
}
export function SeaAnimalButton_click(event) {
wixLocation.to( “/aquatic-animal-collection” );
$w( ‘#SculptureStrip’ ).hide();
}
export function PlantArtButton_click(event) {
wixLocation.to( “/leaf-decor-plant” );
$w( ‘#SculptureStrip’ ).hide();
}
export function HumanArtButton_click(event) {
wixLocation.to( “/human-statues” );
$w( ‘#SculptureStrip’ ).hide();
}
export function DargentaEliteButton_click(event) {
wixLocation.to( “/elite-decor-artists” );
$w( ‘#SculptureStrip’ ).hide();
}
export function FridaKahloButton_click(event) {
wixLocation.to( “/frida-kahlo-art” );
$w( ‘#SculptureStrip’ ).hide();
}
export function SalvadorDaliButton_click(event) {
wixLocation.to( “/salvador-dali-art” );
$w( ‘#SculptureStrip’ ).hide();
}
export function RamirezVazquezButton_click(event) {
wixLocation.to( “/pedro-ramirez-vazquez-statues” );
$w( ‘#SculptureStrip’ ).hide();
}
export function WorldArtButton_click(event) {
wixLocation.to( “/cultural-art” );
$w( ‘#SculptureStrip’ ).hide();
}
export function ReligionButton_click(event) {
wixLocation.to( “/religious-art” );
$w( ‘#SculptureStrip’ ).hide();
}
export function NewArrivalsButton_click(event) {
wixLocation.to( “/new-decoration-arrivals” );
$w( ‘#SculptureStrip’ ).hide();
}
export function MostPopularButton_click(event)
{wixLocation.to( “/most-popular-statues” );
$w( ‘#SculptureStrip’ ).hide();
}
export function GiftConciergeButton_click(event) {
wixLocation.to( “/gift-concierge” );
$w( ‘#SculptureStrip’ ).hide();
}
export function VaseButton_click(event) {
wixLocation.to( “/flower-vase” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function BowlsButton_click(event) {
wixLocation.to( “/bowls” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function PhotoFramesButton_click(event) {
wixLocation.to( “/photo-frames” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function JewellryBoxButton_click(event) {
wixLocation.to( “/jewellery-boxes” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function CandleHolderButton_click(event) {
wixLocation.to( “/candle-holders” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function BookEndButton_click(event) {
wixLocation.to( “/book-ends” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function FruitBowlButton_click(event) {
wixLocation.to( “/fruit-bowls” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function FlowerPotButton_click(event) {
wixLocation.to( “/flower-pots” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function BasketButton_click(event) {
wixLocation.to( “/basket-home-decor” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function ForTableButton_click(event) {
wixLocation.to( “/table-decor” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function ForWallButton_click(event) {
wixLocation.to( “/wall-decor” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function ForFloorButton_click(event) {
wixLocation.to( “/floor-decor-statues” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function ForHerButton_click(event) {
wixLocation.to( “/gifts-for-her-statues” );
$w( ‘#GiftsStrip’ ).hide()
}
export function ForHimButton_click(event) {
wixLocation.to( “/gifts-for-him-home-decor-statues” );
$w( ‘#GiftsStrip’ ).hide()
}
export function TheCoupleButton_click(event) {
wixLocation.to( “/wedding-gifts” );
$w( ‘#GiftsStrip’ ).hide()
}
export function TheHomeButton_click(event) {
wixLocation.to( “/home-decor-collections” );
$w( ‘#GiftsStrip’ ).hide()
}
export function AnimalLoversButton_click(event) {
wixLocation.to( “/animal-statues” );
$w( ‘#GiftsStrip’ ).hide()
}
export function MostPopoularGiftsButton_click(event) {
wixLocation.to( “/popular-home-decor-gifts-statues” );
$w( ‘#GiftsStrip’ ).hide()
}
export function Gifts500Button_click(event) {
wixLocation.to( “/gifts-under-500” );
$w( ‘#GiftsStrip’ ).hide()
}
export function Gift1000Button_click(event) {
wixLocation.to( “/gifts-under-1000” );
$w( ‘#GiftsStrip’ ).hide()
}
export function PersonalizedGiftButton_click(event) {
wixLocation.to( “/bespoke-services” );
$w( ‘#GiftsStrip’ ).hide()
}
export function ShelfButton_click(event) {
wixLocation.to( “/shelf-decor-statues” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function HumanCreationsButton_click(event) {
wixLocation.to( “/human-creation-art” );
$w( ‘#SculptureStrip’ ).hide();
}
export function OurWorlButton_click(event) {
wixLocation.to( “/our-world-home-decor-statues” );
$w( ‘#OurWorldStrip’ ).hide();
}
export function GiftsStrip_mouseIn(event) {
$w( ‘#GiftsStrip’ ).show();
}
export function FuneralUrnButton_click(event) {
wixLocation.to( “/silver-cremation-urns” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function CorpotateGiftButton_click(event) {
wixLocation.to( “/luxury-coporate-gifts” );
$w( ‘#GiftsStrip’ ).hide();
}
export function GardenStatuesButton_click(event) {
wixLocation.to( “/garden-statues” );
$w( ‘#SculptureStrip’ ).hide();
}
export function SilverStatuesButton_click(event) {
wixLocation.to( “/silver-statues” );
$w( ‘#SculptureStrip’ ).hide();
}
export function GoldStatuesButton_click(event) {
wixLocation.to( “/gold-statues” );
$w( ‘#SculptureStrip’ ).hide();
}
export function AbstractStatuesButton_click(event) {
wixLocation.to( “/abstract-statues” );
$w( ‘#SculptureStrip’ ).hide();
}
export function GamesButton_click(event) {
wixLocation.to( “/games-home-decor-statues” );
$w( ‘#HomeDecorStrip’ ).hide();
}
export function GiftConciergeButton2_click(event) {
wixLocation.to( “/gift-concierge” );
$w( ‘#GiftsStrip’ ).hide()
}
export function DargentaLogo_mouseIn_1(event) {
$w( ‘#SculptureStrip’ ).hide();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).hide();
}
export function vectorImage10_mouseIn(event) {
$w( ‘#SculptureStrip’ ).hide();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).hide();
}
export function currencyConverter3_mouseIn(event) {
$w( ‘#SculptureStrip’ ).hide();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).hide();
}
export function accountNavBar2_mouseIn(event) {
$w( ‘#SculptureStrip’ ).hide();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).hide();
}
export function text139_mouseIn(event) {
$w( ‘#SculptureStrip’ ).hide();
$w( ‘#HomeDecorStrip’ ).hide();
$w( ‘#GiftsStrip’ ).hide();
$w( ‘#OurWorldStrip’ ).hide();
}
export function BlogButton_click(event) {
wixLocation.to( “/statues-sculptures-home-decor-blog” );
$w( ‘#OurWorldStrip’ ).hide();
}

You can’t minify this code and you can’t put frontend code in the backend. Refer to Coding with Corvid for details on how to program with Corvid.

This is an old post and is being closed.