<body> <div id="test-div"></div> <script> var testDiv = document.getElementById("test-div"); if (!testDiv.myCustomProperty) insertMyCustomProperty(testDiv); else checkForMyCustomProperty(testDiv); </script> </body>