Inthespiritofopensourcesoftwaredevelopment,jQueryalwaysencouragescommunitycodecontribution.Tohelpyougetstartedandbeforeyoujumpintowritingcode,besuretoreadtheseimportantcontributionguidelinesthoroughly:
Linux/BSDusersshouldusetheirappropriatepackagemanagerstoinstallgitandNode.js,orbuildfromsourceifyouswingthatway.Easy-peasy.
Then,enterthejquerydirectory,installdependencies,andrunthebuildscript:
cdjquerynpminstallnpmrunbuildThebuiltversionofjQuerywillbeplacedinthedist/directory,alongwithaminifiedcopyandassociatedmapfile.
TobuildallvariantsofjQuery,runthefollowingcommand:
npmrunbuild:allThiswillcreateallofthevariantsthatjQueryincludesinarelease,includingjquery.js,jquery.slim.js,jquery.module.js,andjquery.slim.module.jsalongtheirassociatedminifiedfilesandsourcemaps.
ThebuildscriptcanbeusedtocreateacustomversionofjQuerythatincludesonlythemodulesyouneed.
Anymodulemaybeexcludedexceptforcore.Whenexcludingselector,itisnotremovedbutreplacedwithasmallwrapperaroundnativequerySelectorAll(seebelowformoreinformation).
Toseethefulllistofavailableoptionsforthebuildscript,runthefollowing:
Someexamplemodulesthatcanbeexcludedorincludedare:
Note:ExcludingthefullselectormodulewillalsoexcludealljQueryselectorextensions(suchaseffects/animatedSelectorandcss/hiddenVisibleSelectors).
YoucansetthemodulenameforjQuery'sAMDdefinition.Bydefault,itissetto"jquery",whichplaysnicelywithpluginsandthird-partylibraries,buttheremaybecaseswhereyou'dliketochangethis.Passittothe--amdparameter:
npmrunbuild----amd="custom-name"Or,todefineanonymously,leavethenameblank.
npmrunbuild----slim--filename="jquery.slim.js"--dir="/tmp"ThiswouldcreateaslimversionofjQueryandplaceitundertmp/jquery.slim.js.
Bydefault,jQuerygeneratesaregularscriptJavaScriptfile.YoucanalsogenerateanECMAScriptmoduleexportingjQueryasthedefaultexportusingthe--esmparameter:
npmrunbuild----filename=jquery.factory.js--factoryThisoptioncanbemixedwithotherslike--esmor--slim:
Excludeallajaxfunctionality:
npmrunbuild----exclude=ajaxExcludingcssremovesmodulesdependingonCSS:effects,offset,dimensions.
npmrunbuild----exclude=cssExcludeabunchofmodules(-eisanaliasfor--exclude):
npmrunbuild---eajax/jsonp-ecss-edeprecated-edimensions-eeffects-eoffset-ewrapThereisaspecialaliastogenerateabuildwiththesameconfigurationastheofficialjQuerySlimbuild:
npmrunbuild----filename=jquery.slim.js--slimOr,tocreatetheslimbuildasanesmmodule:
npmrunbuild----filename=jquery.slim.module.js--slim--esmNon-officialcustombuildsarenotregularlytested.Usethematyourownrisk.
Makesureyouhavethenecessarydependencies:
npminstallStartnpmstarttoauto-buildjQueryasyouwork:
npmstartRuntheunittestswithalocalserverthatsupportsPHP.Ensurethatyourunthesitefromtherootdirectory,notthe"test"directory.Nodatabaseisrequired.Pre-configuredphplocalserversareavailableforWindowsandMac.Herearesomeoptions:
AsthesourcecodeishandledbytheGitversioncontrolsystem,it'susefultoknowsomefeaturesused.
Ifyouwanttopurgeyourworkingdirectorybacktothestatusofupstream,thefollowingcommandscanbeused(remembereverythingyou'veworkedonisgoneafterthese):
gitconfigbranch.autosetuprebaselocal(seemangit-configformoreinformation)
Ifyou'regettingmergeconflictswhenmerging,insteadofeditingtheconflictedfilesmanually,youcanusethefeaturegitmergetool.Eventhoughthedefaulttoolxxdifflooksawful/old,it'sratheruseful.
Thefollowingaresomecommandsthatcanbeusedthere:
q(...);Example:
testIframe(testName,fileName,functiontestCallback(assert,jQuery,window,document, [additionalargs]){ ...});Thisloadsapage,constructingaurlwithfileName"./data/"+fileName.Theiframedpagedetermineswhenthecallbackoccursinthetestbyincludingthe"/test/data/iframeTest.js"scriptandcallingstartIframeTest([additionalargs])whenappropriate.Oftenthiswillbeaftereitherdocumentreadyorwindow.onloadfires.
ThetestCallbackreceivestheQUnitassertobjectcreatedbytestIframeforthistest,followedbytheglobaljQuery,window,anddocumentfromtheiframe.IftheiframecodepassesanyargumentstostartIframeTest,theyfollowthedocumentargument.