size of stored/saved script

Why does


script myScript
property prop:aValue
end script

store script myScript in file "../myFileName.scpt"

create such a large file, like >400K. If I open it in Script Editor and then save it, the size shrinks to 8K ???

You’re using the script object to store actual data (via properties), which takes up space. If you re-save the file, then the data is no longer in the new file. Like I mentioned before, you can use a hex editor (such as Hex Fiend) to see this for yourself.

Edit: You can also check with load script. Run the first script, save another copy of the result file with Script Editor, and then compare the two with the second script (changing the file name as needed).

script myScript
	property exampleProperty : "Hello, World!"
end script

do shell script "/usr/bin/jot 1000 10 10000"
set exampleProperty of myScript to paragraphs of result

store script myScript in file ((path to home folder as Unicode text) & "test.scpt")
set test to load script file ((path to home folder as Unicode text) & "test.scpt")

exampleProperty of test