{"_id":"54cc2149380ecd0d00ca18d5","parentDoc":null,"project":"5436a1e1d0ffee0e00f18f8c","__v":0,"user":"5436a1afb7cf0e1c0020d9ca","version":{"_id":"54cc2148380ecd0d00ca18aa","__v":2,"forked_from":"5436a1e1d0ffee0e00f18f8f","project":"5436a1e1d0ffee0e00f18f8c","createdAt":"2015-01-31T00:26:48.753Z","releaseDate":"2015-01-31T00:26:48.753Z","categories":["54cc2149380ecd0d00ca18ab","54cc2149380ecd0d00ca18ac","54cc2149380ecd0d00ca18ad","54cc2149380ecd0d00ca18ae","54cc2149380ecd0d00ca18af","54cc2149380ecd0d00ca18b0","54cc2149380ecd0d00ca18b1","54cc2149380ecd0d00ca18b2","54cc2149380ecd0d00ca18b3","552f29ca633a5b0d00e99d09"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.1.0","version":"1.1"},"category":{"_id":"54cc2149380ecd0d00ca18ae","__v":2,"pages":["54cc2149380ecd0d00ca18d2","54cc2149380ecd0d00ca18d3","54cc2149380ecd0d00ca18d4","54cc2149380ecd0d00ca18d5","555236587988e10d003452e9"],"project":"5436a1e1d0ffee0e00f18f8c","version":"54cc2148380ecd0d00ca18aa","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-09T15:31:35.377Z","from_sync":false,"order":3,"slug":"easyship-widget","title":"EasyShip Widget"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-12-10T18:41:53.496Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"never","params":[],"url":""},"isReference":false,"order":4,"body":"By default EasyShip is initialized simply by including the javascript via a `script` tag. However, there are times that you may want to defer initialization in order to hook into the initialization process. In order to reliably configure these hooks you will need to set the `data-defer-initialization` data attribute on your script tag and manually initialize EasyShip at a later  time.  \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Example\"\n}\n[/block]\n```\n<script\n  src=\"https://app.shippingeasy.com/easyship.js\"\n  data-partner-key=\"XXX\"\n  data-token=\"dc02eec82448924a6a8d0ad4a1174af41e342fc2d45962e702ac137bd\"\n  data-defer-initialization=\"true\">\n</script>\n\n<script>\n  EasyShip.beforeInit = function() {\n    alert(\"Before initialization\");\n  }\n  EasyShip.init();\n</script>\n```\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"beforeInit\"\n}\n[/block]\nExecutes before the EasyShip library initializes and loads its assets.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"EasyShip.beforeInit = function() {\\n    alert(\\\"Before initialization\\\");\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"afterInit\"\n}\n[/block]\nExecutes after the EasyShip library initializes and loads its assets.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"EasyShip.afterInit = function() {\\n    alert(\\\"After initialization\\\");\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"advanced-options","type":"basic","title":"Advanced Options"}
By default EasyShip is initialized simply by including the javascript via a `script` tag. However, there are times that you may want to defer initialization in order to hook into the initialization process. In order to reliably configure these hooks you will need to set the `data-defer-initialization` data attribute on your script tag and manually initialize EasyShip at a later time. [block:api-header] { "type": "basic", "title": "Example" } [/block] ``` <script src="https://app.shippingeasy.com/easyship.js" data-partner-key="XXX" data-token="dc02eec82448924a6a8d0ad4a1174af41e342fc2d45962e702ac137bd" data-defer-initialization="true"> </script> <script> EasyShip.beforeInit = function() { alert("Before initialization"); } EasyShip.init(); </script> ``` [block:api-header] { "type": "basic", "title": "beforeInit" } [/block] Executes before the EasyShip library initializes and loads its assets. [block:code] { "codes": [ { "code": "EasyShip.beforeInit = function() {\n alert(\"Before initialization\");\n}", "language": "javascript" } ] } [/block] [block:api-header] { "type": "basic", "title": "afterInit" } [/block] Executes after the EasyShip library initializes and loads its assets. [block:code] { "codes": [ { "code": "EasyShip.afterInit = function() {\n alert(\"After initialization\");\n}", "language": "javascript" } ] } [/block]